package net.tng.strutsEjb.web.user;

import javax.ejb.EJB;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.tng.strutsEjb.core.service.IUserService;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class UserBuilder extends Action {

    @EJB(name = IUserService.EJB_NAME)
    IUserService service;

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        UserForm myForm = (UserForm) form;
        myForm.initForm();

        myForm.setUsers(service.getAllUsers());

        return mapping.findForward("success");
    }
}
